package com.ujs.service.impl;

import com.ujs.dao.ProductDao;
import com.ujs.pojo.Product;
import com.ujs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @title: ProductServiceImpl
 * @Author liyunxiao
 * @Date: 2021/1/10 19:49
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;
    @Override
    public List<Product> findAll() {
        return productDao.findAll();
    }

    @Override
    public Product findById(String id) {
        return productDao.getOne(id);
    }

    @Override
    public void save(Product product) {
        productDao.save(product);
    }
    @Override
    public void deleteById(String id){
        System.out.println("service删除的id为"+id);
        productDao.deleteById(id);
    }
    @Override
    public List<Product> findByProductNameLike( String name) {
        return productDao.findByProductNameLike("%"+name+"%");
    }
}
